﻿
using System;


namespace CrazyMan.TM.Interface.Domain
{
    /// <summary>
    /// Represents a betting schedule interval.
    /// </summary>
    public abstract class Interval
    {
        private int _duration; //in minutes

        /// <summary>
        /// Creates a new betting schedule interval.
        /// </summary>
        public Interval()
        {
            this._duration = 0;
        }

        /// <summary>
        /// Creates a new betting schedule interval with the specified duration.
        /// </summary>
        /// <param name="duration">The duration of the interval.</param>
        public Interval(int duration)
        {
            ValidateDuration(duration);
            this._duration = duration;
        }

        /// <summary>
        /// Gets and sets the duration of the interval in minutes.
        /// </summary>
        public int Duration
        {
            get { return this._duration; }
            set 
            {
                ValidateDuration(value);
                this._duration = value; 
            }
        }

        /// <summary>
        /// Validates that the duration is a valid number.
        /// </summary>
        /// <param name="duration">The duration to be validated.</param>
        protected void ValidateDuration(int duration)
        {
            //TODO: look at using a string resource file
            if (duration < 0)
                throw new ArgumentOutOfRangeException("duration", "Duration can not be less than zero.");
        }
    }
}
